'''
官方文档: https://docs.python.org/zh-cn/3.7/library/threading.html
'''
from threading import Thread
import time


def func(name=""):
    print(f"hello threading!{name}\n")
    time.sleep(3)  # 暂停10s
    print(f"{name} end!\n")


def run_thread():
    t1 = Thread(target=func, args=("线程1",))
    t2 = Thread(target=func, args=("线程2",))
    t3 = Thread(target=func, args=("线程3",))
    # run方法用于 自定义Thread类 重写
    # run方法 会在线程启动的时候 被默认调用
    t1.start()
    t2.start()
    t3.start()
    # join方法可以等待三个线程先执行完成 再回到主线程
    t1.join()
    t2.join()
    t3.join()


if __name__ == "__main__":
    run_thread()
    print("主线程执行！")
